package com.example.champtionthree.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ExamInfo implements  Parcelable{
    public boolean success;
    public List<ItemInfo> data;

    protected ExamInfo(Parcel in) {
        success = in.readByte() != 0;
        data = in.createTypedArrayList(ItemInfo.CREATOR);
    }

    public static final Creator<ExamInfo> CREATOR = new Creator<ExamInfo>() {
        @Override
        public ExamInfo createFromParcel(Parcel in) {
            return new ExamInfo(in);
        }

        @Override
        public ExamInfo[] newArray(int size) {
            return new ExamInfo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (success ? 1 : 0));
        dest.writeTypedList(data);
    }

    public static  class ItemInfo implements Parcelable{
        public  String name;
        public ArrayList<SmallItemInfo> albums;

        protected ItemInfo(Parcel in) {
            name = in.readString();
            albums = in.createTypedArrayList(SmallItemInfo.CREATOR);
        }

        public static final Creator<ItemInfo> CREATOR = new Creator<ItemInfo>() {
            @Override
            public ItemInfo createFromParcel(Parcel in) {
                return new ItemInfo(in);
            }

            @Override
            public ItemInfo[] newArray(int size) {
                return new ItemInfo[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(name);
            dest.writeTypedList(albums);
        }
    }
    public static class SmallItemInfo implements Parcelable {
        public String image_url;
        public String name;
        public String description;
        public String video_count;

        protected SmallItemInfo(Parcel in) {
            image_url = in.readString();
            name = in.readString();
            description = in.readString();
            video_count = in.readString();
        }

        public static final Creator<SmallItemInfo> CREATOR = new Creator<SmallItemInfo>() {
            @Override
            public SmallItemInfo createFromParcel(Parcel in) {
                return new SmallItemInfo(in);
            }

            @Override
            public SmallItemInfo[] newArray(int size) {
                return new SmallItemInfo[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(image_url);
            dest.writeString(name);
            dest.writeString(description);
            dest.writeString(video_count);
        }
    }

}
